<?php
namespace Admin\Controller;
use Think\Controller;
/**
 * 设置Api控制器
 */
 class SetApiController extends  IsLoginController{
 	public function SetApi(){
 		if(IS_POST){
			$userApi = D('wxapi');
			if(!$userApi->addApi()){
	  			$this->error($userApi->getError());
	  		}
			$this->success('Api配置信息保存成功');
	 	}
		//更具当前登录的用户id查询用户api配置信息分配视图
		$uid = $_SESSION['uid'];
		$url = 'http://'.$_SERVER['HTTP_HOST'] . U('weixin/index/index',array('uid'=>$uid));
		$url = str_ireplace("/admin.php","/index.php",$url);
		$userInfo = M('wxapi')->where("wxuid='{$uid}'")->find();
		$this->assign('userInfo',$userInfo)
			 ->assign("url",$url);
		$this->display();
 	}
 }
